/**
 * Copyright (c) Software Institute of PKU
 * All rights reserved. 
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 */
package edu.pku.sei.transformation.editor.views.figures;

import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.FlowLayout;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.LineBorder;
import org.eclipse.draw2d.MarginBorder;
import org.eclipse.draw2d.ToolbarLayout;
import org.eclipse.swt.graphics.Color;

import edu.pku.notation.runtime.constance.ColorConstance;
import edu.pku.sei.modeler.figures.CommonFigure;
import edu.pku.sei.transformation.editor.views.icons.IconsProvider;

/**
 * @generated
 * 
 */
public class ObjectVariableFigure extends CommonFigure implements
		ITemplateFigure {
	public static final org.eclipse.swt.graphics.Color OBEJCTTEMPLATE_COLOR = new Color(
			null, 175, 178, 239);
	private Label head = new Label("name");
	private Figure body = new Figure();
	private LineBorder border = new LineBorder(1);
	private static final int BODY_MARGIN = 1;
	private static final int HEAD_MARGIN =1;

	public ObjectVariableFigure() {
		ToolbarLayout layout = new ToolbarLayout();
		layout.setVertical(true);
		setLayoutManager(layout);
		setBackgroundColor(OBEJCTTEMPLATE_COLOR);
		setBorder(border);

		head.setFont(FontConstant.TITLE_FONT);
		
		FlowLayout bodylayout = new FlowLayout();
		bodylayout.setHorizontal(false);
		body.setLayoutManager(bodylayout);
		body
				.setBorder(new ContainerBorder(ColorConstance.BLACK, 1, BODY_MARGIN, BODY_MARGIN,
						BODY_MARGIN, BODY_MARGIN));

		head.setBorder(new MarginBorder(HEAD_MARGIN));
		head.setIcon(IconsProvider.getImage(IconsProvider.NODE_ICO));

		this.add(head);
		this.add(body);

	}
	public void setHeadText(String headText) {
		this.head.setText(headText);
	}

	@Override
	public Label getNameLabel() {
		return this.head;
	}

	public Figure getBody() {
		return this.body;
	}

	public void hightLight(boolean isHighLight) {
		if (isHighLight) {
			this.border.setColor(ColorConstance.BLUE);			
		} else {
			this.border.setColor(ColorConstance.BLACK);
		}
		this.repaint();
	}
}
